<style>
    .pageFormContent p{
        float:none;
    }



    .yuns label{
        width:auto;
        padding:0px 10px;
    }

    .pageFormContent .textInput{
        width:40px;
        float:none;
    }

    .pageFormContent p{
        width:auto;
    }

    ._citys {    display:none; background: #fff;width: 450px; z-index:1000;display: inline-block; border: 2px solid #eee; padding: 5px; position: relative; }
    ._citys span { color: #56b4f8; height: 15px; width: 15px; line-height: 15px; text-align: center; border-radius: 3px; position: absolute; right: 10px; top: 10px; border: 1px solid #56b4f8; cursor: pointer; }
    ._citys0 { width: 100%; height: 34px; display: inline-block; border-bottom: 2px solid #56b4f8; padding: 0; margin: 0; }
    ._citys0 li { display: inline-block; line-height: 34px; font-size: 15px; color: #888; width: 80px; text-align: center; cursor: pointer; }
    .citySel { background-color: #56b4f8; color: #fff !important; }
    ._citys1 { width: 100%; display: inline-block; padding: 10px 0; }
    ._citys1 a { width: 83px; height: 35px; display: inline-block; background-color: #f5f5f5; color: #666; margin-left: 6px; margin-top: 3px; line-height: 35px; text-align: center; cursor: pointer; font-size: 13px; overflow: hidden; }
    ._citys1 a:hover { color: #fff; background-color: #56b4f8; }
    .AreaS { background-color: #56b4f8 !important; color: #fff !important; }



</style>
<div class="pageContent">

    <form method="post" action="index.php?c=Fare&a=myChange" class="pageForm required-validate" onsubmit="return validateCallback(this,dialogAjaxDone);">

        <div class="pageFormContent" layoutH="56">
            <div style="padding-bottom:20px;border-bottom:1px solid #eaeaea">添加运费模板:</div>
            <p>
                <label>模板名称：</label>
                <input name="name" type="text" value="{$Obj.name}" size="30" class="required" style="width:100px;" />
            </p>
			<p>
                <label>商家id：</label>

                <select name="shopid">
                    <volist name="shopList" id="shopItem">
                        <if condition="$shopItem.shopid == $Obj.shopid ">
                            <option  value="{$shopItem.shopid}" selected="selected">{$shopItem.name}</option>
                            <elseif condition="$shopItem.shopid != $Obj.shopid "/><option  value="{$shopItem.shopid}">{$shopItem.name}</option>
                        </if>
                    </volist>
                </select>

            </p>
            <p>
                <label>发货时间：</label>

                <select name="deliverytime">
                    <volist name="classifyList" id="classify">
                        <if condition="$classify.time == $Obj.deliverytime ">
                            <option  value="{$classify.time}" selected="selected">{$classify.time}</option>
                            <elseif condition="$classify.time != $Obj.deliverytime"/><option  value="{$classify.time}">{$classify.time}</option>
                        </if>
                    </volist>
                </select>

            </p>
            <p>
                <label>是否包邮：</label>
                <if condition="$Obj.isPay == 0 ">
                    <input type="radio" name="isPay" value="0" checked="checked"/>自定义运费
                    <else /><input type="radio" name="isPay" value="0" />自定义运费
                </if>
                <if condition="$Obj.isPay == 1 ">
                    <input type="radio" name="isPay" value="1" checked="checked"/>卖家出运费
                    <else /><input type="radio" name="isPay" value="1"/>卖家出运费
                </if>
            </p>

            <p>
                <label>计价方式：</label>
                <if condition="$Obj.type == 0 ">
                    <input type="radio" name="Paymethod" value="0" checked="checked" class="payM"/>按件数

                </if>
                <if condition="$Obj.type == 1 ">
                    <input type="radio" name="Paymethod" value="1" class="payM" checked="checked"/>按重量
                </if>
            </p>
            <input type="text" name="muid" value="{$Obj.id}" hidden="hidden" />

            <if condition="$Obj.type == 1 ">
                <div style="border:1px solid dodgerblue;padding:20px;" class="yuns" id="zhong">
                    <label>默认运费：</label>
                    <input type="text" name="area[]" class="required" value="0" hidden="hidden"/>
                    <input type="text" name="begincount[]" class="required" value="{$mo.begincount}"/>kg内,
                    <input type="text" name="fare[]" class="required" value="{$mo.fare}"/>多少元，
                    每增加<input type="text" name="quantity[]" class="required" value="1"/>kg增加运费
                    <input type="text" name="addfare[]" class="required" value="{$mo.addfare}"/>元

                    <volist name="addList" id="yunitem">
                        <p style="margin-left:10px">
                            <input type="text" name="area[]" value="{$yunitem.area}" style="width: 150px" class="city required"/>
                            <label style="float:none">默认运费：</label>
                            <input type="text" name="begincount[]" value="{$yunitem.begincount}" class="required" style="width:40px;"/>kg内,
                            <input type="text" name="fare[]" class="required" value="{$yunitem.fare}" style="width:40px;"/>多少元，
                            每增加<input type="text" name="quantity[]"  class="required"  style="width:40px;" value="1"/>kg增加运费
                            <input type="text" name="addfare[]"  class="required" style="width:40px;" value="{$yunitem.addfare}"/>元
                            <span style="margin-left:10px;font-size:12px;color:blue;cursor: pointer" id="rem" >删除</span>
                        </p>

                    </volist>


                    <div style="display:block;color:blue;margin-top:10px;margin-left:10px;cursor: pointer" class="addMore">为指定地点设置运费</div>
                </div>


            </if>
            <if condition="$Obj.type == 0 ">
                <div style="border:1px solid dodgerblue;padding:20px;" class="yuns" id="jian">
                    <label>默认运费：</label>
                    <input type="text" name="area[]" class="required" value="0" hidden="hidden"/>
                    <input type="text" name="begincount[]" class="required" value="{$mo.begincount}"/>件内,
                    <input type="text" name="fare[]" class="required" value="{$mo.fare}"/>多少元，
                    每增加<input type="text" name="quantity[]" class="required" value="1"/>件增加运费
                    <input type="text" name="addfare[]" class="required" value="{$mo.addfare}"/>元

                    <volist name="addList" id="yunitem">
                        <p style="margin-left:10px">
                            <input type="text" name="area[]" value="{$yunitem.area}" style="width: 150px" class="city required"/>
                            <label style="float:none">默认运费：</label>
                            <input type="text" name="begincount[]" value="{$yunitem.begincount}" class="required" style="width:40px;"/>件内,
                            <input type="text" name="fare[]" class="required" value="{$yunitem.fare}" style="width:40px;"/>多少元，
                            每增加<input type="text" name="quantity[]"  class="required"  style="width:40px;" value="1"/>件增加运费
                            <input type="text" name="addfare[]"  class="required" style="width:40px;" value="{$yunitem.addfare}"/>元
                            <span style="margin-left:10px;font-size:12px;color:blue;cursor: pointer" class="rem" >删除</span>
                        </p>
                    </volist>


                    <div style="display:block;color:blue;margin-top:10px;margin-left:10px;cursor: pointer" class="addMore">为指定地点设置运费</div>
                </div>
            </if>

        </div>
        <div class="formBar">
            <ul>
                <li><div class="buttonActive"><div class="buttonContent"><button type="submit">保存</button></div></div></li>
                <li>
                    <div class="button"><div class="buttonContent"><button type="button" class="close">取消</button></div></div>
                </li>
            </ul>
        </div>
    </form>
</div>

<script>

    var type = "{$Obj.type}";
    $(function(){
        var $jian = $("#jian");
        var $zhong = $("#zhong");
        $('.payM').click(function(){
            var index = $(this).index();

            if(index == 1){
                $jian.css('display','block');
                $zhong.css('display','none');
            }else{
                $jian.css('display','none');
                $zhong.css('display','block');
            }
        })

        $('.rem').click(function(){
            $(this).parent().remove();
            e.stopPropagation();
        })

        $('.addMore').click(function(){
            if(type == 0){
                $newNode = $('<p style="margin-left:10px">' +
                    '<input type="text" name="area[]" value="" style="width: 150px" class="city required"/>' +
                    '<label style="float:none">默认运费：</label>' +
                    '<input type="text" name="begincount[]" value="1" class="required" style="width:40px;"/>kg内,' +
                    '<input type="text" name="fare[]" class="required" value="" style="width:40px;"/>多少元，' +
                    '每增加<input type="text" name="quantity[]"  class="required"  style="width:40px;" value="1"/>kg增加运费' +
                    '<input type="text" name="addfare[]"  class="required" style="width:40px;" value=""/>元' +
                    '<span style="margin-left:10px;font-size:12px;color:blue;cursor: pointer" id="rem" >删除</span>' +

                    '</p>');
                $newNode.insertBefore($(this));

                $newNode.find("#rem").click(function (e) {
                    $(this).parent().remove();
                    e.stopPropagation();
                });

                $newNode.find('.city').click(function (e) {
                    SelCity(this, e);
                    console.log("inout", $(this).val(), new Date())
                });
            }else {
                $newNode = $('<p style="margin-left:10px">' +
                    '<input type="text" name="area[]" value="" style="width: 150px" class="city required"/>' +
                    '<label style="float:none">默认运费：</label>' +
                    '<input type="text" name="begincount[]" value="1" class="required" style="width:40px;"/>kg内,' +
                    '<input type="text" name="fare[]" class="required" value="" style="width:40px;"/>多少元，' +
                    '每增加<input type="text" name="quantity[]"  class="required"  style="width:40px;" value="1"/>kg增加运费' +
                    '<input type="text" name="addfare[]"  class="required" style="width:40px;" value=""/>元' +
                    '<span style="margin-left:10px;font-size:12px;color:blue;cursor: pointer" id="rem" >删除</span>' +
                    '</p>');
                $newNode.insertBefore($(this));

                $newNode.find("#rem").click(function (e) {
                    $(this).parent().remove();
                    e.stopPropagation();
                })
                $newNode.find('.city').click(function (e) {
                    SelCity(this, e);
                    console.log("inout", $(this).val(), new Date())
                });
            }
        })
    })





</script>
